<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">入库作业单编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="workNo"  id="workNo" class="layui-input" type="text" placeholder="请输入入库作业单编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料编码：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" id="skuCode" class="layui-input" type="text" placeholder="请输入物料编码"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuName"  id="skuName" class="layui-input" type="text" placeholder="请输入物料名称"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">库位：</label>
                                    <div class="layui-input-inline">
                                        <input name="warehouseShelfSpaceCode" id="warehouseShelfSpaceCode" class="layui-input" type="text" placeholder="请输入库位"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">入库时间：</label>
                                    <div class="layui-input-inline">
                                        <input id="pTime" class="layui-input date-icon" type="text"
                                               placeholder="选择入库时间"
                                               autocomplete="off" readonly/>
                                        <input name="startCreateTime" id="startCreateTime" style="display: none"/>
                                        <input name="endCreateTime" id="endCreateTime" style="display: none"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button type="button" class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true">查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                            <button type="button" id="purchaseStorageWorkBtnAdd" class="layui-btn icon-btn color-reseda">添加入库作业单</button>
                            <button type="button" id="simpleAddBtn" class="layui-btn icon-btn color-reseda">简易入库</button>
                            <button id="workStorageBtnExport" class="layui-btn icon-btn color-green">导出</button>
                        </div>
                        <div class="lay-btn-rt">
                        </div>
                    </div>
                </div>
            </div>

            <!-- 表格 -->
            <table class="layui-table" id="purchaseStorageWorkTable" lay-filter="purchaseStorageWorkTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列2 -->
<script type="text/html" id="purchaseStorageWorkTableBar">
    <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">详情</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="purchaseStorageWorkForm">
    <form lay-filter="purchaseStorageWorkForm" class="layui-form model-form">
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">采购订单</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="purchaseOrderId" name="purchaseOrderId" lay-filter="purchaseOrderId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">供应商联系人</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="businessContact" class="layui-input"/>
                </div>
            </div>
        </div>

        <input name="warehouseId" type="hidden"/>
        <div style="margin-left: 30px;">
            <table class="layui-table">
                <thead>
                <tr style="">
                    <td style="width: 150px; text-align: center;">采购入库签收编号</td>
                    <td style="width: 120px; text-align: center;">供应商联系人</td>
                    <td style="width: 120px; text-align: center;">采购部门</td>
                    <td style="width: 120px; text-align: center;">采购申请人</td>
                    <td style="width: 120px; text-align: center;">订单审核人</td>
                    <td style="width: 120px; text-align: center;">运输方式</td>
                    <td style="width: 150px; text-align: center;">运单编号</td>
                    <td style="width: 150px; text-align: center;" id="variable">车牌号</td>
                    <td style="width: 120px; text-align: center;">电话</td>
                    <td style="width: 120px; text-align: center;">入库仓库</td>
                </tr>
                </thead>
                <tbody>
                <tr class="layui-form componentTr" >
                    <td id="signNo" class="typeTd">
                        <select name="purchaseSignForId" lay-filter="getPurchaseSignFor" lay-verify="required" required></select>
                    </td>
                    <td id="businessContact" style="text-align: center;"></td>
                    <td id="departmentName" style="text-align: center;"></td>
                    <td id="purchaseApplicant" style="text-align: center;"></td>
                    <td id="auditorName" style="text-align: center;"></td>
                    <td id="transportModeDesc" style="text-align: center;"></td>
                    <td id="waybillNo" style="text-align: center;"></td>
                    <td id="plateNo" style="text-align: center;"></td>
                    <td id="phone" style="text-align: center;"></td>
                    <td id="warehouseName" style="text-align: center;"></td>
                </tr>
                </tbody>
            </table>

            <div class="layui-btn" id="addProduct" style="margin-top: 10px;">添加入库作业物料</div>

            <div id="productList">
                <table class="layui-table" id="purchaseStorageWorkProductTable" lay-filter="purchaseStorageWorkProductTable"></table>
            </div>
        </div>

        <div class="layui-form-item text-center" style="margin-top: 50px;">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="purchaseStorageWorkFormSubmit" lay-submit>提交</button>
        </div>
    </form>
</script>


<!--入库作业物料-->
<script type="text/html" id="purchaseStorageWorkProductList">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">物料编号：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="skuCode" class="layui-input" type="text" placeholder="请输入物料编号"/>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">物料名称：</label>
                                        <div class="layui-input-inline mr0">
                                            <input name="productName" class="layui-input" type="text" placeholder="请输入物料名称"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green" lay-filter="deliveryRecordProductFormSubSearchLog" lay-submit>查询</button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="deliveryRecordProductResets" lay-submit>重置</button>
                                        <button class="layui-btn layui-btn-normal icon-btn" id="confirmChoose">确认选择</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="purchaseSignForProductTable" lay-filter="purchaseSignForProductTable"></table>
            </div>
        </div>
    </div>
</script>

<!-- 表格操作列 -->
<script type="text/html" id="purchaseDeliveryRecordProductTableBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>


<!-- 详情弹窗 -->
<script type="text/html" id="purchaseStorageWorkView">
    <form lay-filter="purchaseStorageWorkView" class="layui-form model-form">
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库类型</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseInventoryTypeName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库作业单</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="workNo" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库签收单</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="signNo" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">签收任务单</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="logisticsNo" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">运单编号</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="waybillNo" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库物料编码</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="skuCode" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库物料名称</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="skuName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库物料规格</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="skuSpec" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库仓库类型</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseTypeName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库仓库</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">仓库库区</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseAreaName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">库区货架</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseShelfName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">货架货位</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="warehouseShelfSpaceCode" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">货位料箱</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="palletBoxCode" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库单位</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="mainUnitName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库数量</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="quantity" class="layui-input" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">辅计量单位数量</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" id="sunUnitNum" name="sunUnitNum" class="layui-input" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!-- 添加入库作业弹窗 -->
<script type="text/html" id="storageWorkAddForm">
    <form lay-filter="storageWorkAddForm" class="layui-form model-form">
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库类型</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseInventoryTypeId" name="warehouseInventoryTypeId" lay-filter="warehouseInventoryTypeId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库签收单</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="purchaseSignForId" name="purchaseSignForId" lay-filter="purchaseSignForId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">签收入库产品</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="hidden" id="productDetailId" name="productDetailId"/>
                    <input type="hidden" id="mainUnitId" name="mainUnitId"/>
                    <input type="hidden" id="mainUnitRate" name="mainUnitRate"/>
                    <input type="hidden" id="subUnitId" name="subUnitId"/>
                    <input type="hidden" id="subUnitName" name="subUnitName"/>
                    <input type="hidden" id="subUnitRate" name="subUnitRate"/>
                    <select id="purchaseSignForProductId" name="purchaseSignForProductId" lay-filter="purchaseSignForProductId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">签收数量</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" id="signNum" name="signNum" class="layui-input" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库仓库类型</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseTypeId" name="warehouseTypeId" lay-filter="warehouseTypeId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库仓库</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseId" name="warehouseId" lay-filter="warehouseId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">仓库库区</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseAreaId" name="warehouseAreaId" lay-filter="warehouseAreaId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">库区货架</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseShelfId" name="warehouseShelfId" lay-filter="warehouseShelfId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">货架货位</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <select id="warehouseShelfSpaceId" name="warehouseShelfSpaceId" lay-filter="warehouseShelfSpaceId" lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">货位料箱</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="hidden" id="palletBoxId" name="palletBoxId"/>
                    <input type="text" id="palletBoxName" name="palletBoxName" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库单位</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" id="purchaseStorageWorkUnitName" name="purchaseStorageWorkUnitName" class="layui-input" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">入库数量</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" name="quantity" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4">
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 100px;">辅计量单位数量</label>
                <div class="layui-input-block" style="margin-left: 130px;">
                    <input type="text" id="subStorageWorkNum" name="subStorageWorkNum" class="layui-input" disabled/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn" lay-filter="purchaseStorageWorkFormAddSubmit" lay-submit>提交</button>
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!--料箱操作按钮-->
<script type="text/html" id="storageWorkBinListTableBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="add">添加入库信息</a>
</script>

<!--货位操作按钮-->
<script type="text/html" id="warehouseShelfSpaceTableBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="add">添加入库信息</a>
</script>

<!--入库签收单-->
<script type="text/html" id="storageCodeTemplate">
    <form lay-filter="storageCodeForm" class="layui-form model-form" style="padding: 0;">
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 240px;">
                <input name="storageCode" value="{{d.storageCode != null ? d.storageCode : ''}}" type="text" class="layui-input" placeholder="请输入签收单号"/>
            </div>
            <div class="layui-input-inline" style="margin-left: 5px;">
                <a class="layui-btn icon-btn color-green" id="storageCodeConfig">确定</a>
            </div>
        </div>
    </form>
</script>

<!--物料编号-->
<script type="text/html" id="storageProductTemplate">
    <form lay-filter="storageProductForm" class="layui-form model-form" style="padding: 0;">
        <select name="storageProductSku" id="storageProductSku" lay-filter="storageProductSku" lay-verify="required">
            <option value="">请选择入库物料</option>
        </select>
    </form>
</script>

<!--选择仓库-->
<script type="text/html" id="warehouseTemplate">
    <form lay-filter="warehouseTemplateForm" class="layui-form model-form" style="padding: 0;">
        <select name="storageWarehouse" id="storageWarehouse" lay-filter="storageWarehouse" lay-verify="required">
        </select>
    </form>
</script>


<!--入库信息弹窗-->
<script type="text/html" id="storageInfoAddForm">
    <form lay-filter="storageInfoAddForm" class="layui-form model-form" style="padding: 5px 30px 0 30px;height: calc(100% - 5px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 75px);">
            <table class="layui-table" id="storageProductTable" lay-filter="storageProductTable"></table>

            <div class="layui-row table-bor isSelectCode" style="margin-top: 15px;">
                <div class="layui-form-item">
                    <label class="layui-form-label w-auto">输入包装码</label>
                    <div class="layui-input-inline" style="width: 260px;">
                        <input name="workLabelCode" type="text" class="layui-input workBinCode" placeholder="请输入包装码" style="width: 100%;"/>
                    </div>
                    <div class="layui-input-inline">
                        <button class="layui-btn icon-btn color-green" id="addWorkLabelCode">添加签收信息</button>
                    </div>
                </div>
                <div class="isSignLabelCode scroll-table-4" style="display: none" id="productList">
                    <table class="layui-table" id="storageInfoListTable" lay-filter="storageInfoListTable"></table>
                </div>
            </div>
            <div class="layui-row isSignLabelCode" style="display: none;margin-top: 15px;">
                <div class="layui-form-item">
                    <label class="layui-form-label">入库作业人</label>
                    <div class="layui-input-inline">
                        <input name="signStationName" placeholder="请输入入库作业人" type="text" class="layui-input" readonly="readonly"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">作业说明</label>
                    <div class="layui-input-inline">
                        <input name="remark" placeholder="请输入入库作业说明" type="text" class="layui-input"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="storageInfoAddFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>


<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var storageName = '', skuCode = ''; // 入库类型
        laydate.render({
            elem: '#pTime',
            type: 'date',
            range: true,
            done: function (value, date, endDate) {
                if (value) {
                    var dateValue = value.split(" - ");
                    $("input[name='startCreateTime']").val(dateValue[0] + " 00:00:00");
                    $("input[name='endCreateTime']").val(dateValue[1] + " 23:59:59");
                } else {
                    $("input[name='startCreateTime']").val("");
                    $("input[name='endCreateTime']").val("");
                }
            }
        });

        // 渲染表格
        var insTb = table.render({
            elem: '#purchaseStorageWorkTable',
            url: config.base + 'enterprise/purchase/admin/purchaseStorageWork/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', width: 50, title: "序号"}
                ,{field: 'workNo', align:'center', title: '入库作业单编号', width: 150}
                ,{field: 'signNo', align:'center', title: '入库签收单编号', width: 150}
                ,{field: 'logisticsNo', align:'center', title: '签收任务编号', width: 150}
                ,{field: 'waybillNo', align:'center', title: '运单编号'}
                ,{field: 'skuCode', align:'center', title: '入库物料编码'}
                ,{field: 'skuName', align:'center', title: '入库物料名称'}
                ,{field: 'skuSpec', align:'center', title: '入库物料规格'}
                ,{field: 'warehouseName', align:'center', title: '入库仓库'}
                ,{field: 'quantity', align:'center', title: '入库数量'}
                ,{field: 'createTime', align:'center', title: '入库时间', width: 140}
                ,{align: 'center', toolbar: '#purchaseStorageWorkTableBar', title: '操作',}
            ]]
        });

        // 工具条点击事件
        table.on('tool(purchaseStorageWorkTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'view') { // 查看
                showViewModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }
        });

        //监听排序
        table.on('sort(purchaseStorageWorkTable)', function(obj){
            table.reload('purchaseStorageWorkTable', {
                initSort: obj,
                where: {
                    sort: obj.field,
                    order: obj.type
                }
            });
        });

        // 添加按钮点击事件
        $('#purchaseStorageWorkBtnAdd').click(function () {
            admin.formOpen({
                area: ['90%', '85%'],
                offset: '50px',
                title: '添加入库作业',
                path: 'components/purchase/purchaseStorageWorkForm.html',
                success: function () {
                    parentData.eventName = 'add'
                }
            })
            // storageWorkAddModel();
        });
        // 简易入库
        $('#simpleAddBtn').click(function () {
            admin.formOpen({
                area: ['90%', '85%'],
                title: '添加入库作业',
                path: 'components/purchase/purchaseStorageWorkForm.html',
                success: function () {
                    parentData.eventName = 'simpleAdd';
                }
            })
        });
        // 添加采购入库作业
        function storageWorkAddModel() {
            storageName = '';
            skuCode = '';
            admin.open({
                type: 1,
                area: '1200px',
                offset: '120px',
                title: '添加采购入库作业单',
                content: $('#storageWorkAddForm').html(),
                success: function () {
                    //入库类型列表
                    admin.initDataSelect("enterprisecab/warehouse/admin/warehouseInventoryType/list", {limit: 999, inventoryType: 'in'}, "warehouseInventoryTypeId", null, "入库类型", null, null);
                    //入库签收单列表
                    admin.initDataSelect("enterprise/purchase/admin/purchaseSignFor/list", {limit: 999, status: '2'}, "purchaseSignForId", null, "入库签收单", "signNo", null);
                    //入库签收单选择事件
                    form.on("select(purchaseSignForId)", function (selectData) {
                        $("#purchaseSignForProductId").empty();
                        //入库签收产品列表
                        admin.initDataSelect("enterprise/purchase/admin/purchaseSignForProduct/list", {limit: 999, purchaseSignForId: selectData.value}, "purchaseSignForProductId", null, "入库签收产品", "skuCode", null);
                    });
                    //签收入库产品选择事件
                    form.on("select(purchaseSignForProductId)", function (selectData) {
                        //入库签收产品信息
                        admin.req('enterprise/purchase/admin/purchaseSignForProduct/list', {id: selectData.value}, function(res) {
                            if (200 == res.code) {
                                console.info(res.data, 9091);
                                $("#productDetailId").val(res.data[0].productDetailId);
                                $("#purchaseStorageWorkUnitName").val(res.data[0].mainUnitName);
                                $("#mainUnitId").val(res.data[0].mainUnitId);
                                $("#mainUnitRate").val(res.data[0].mainUnitRate);
                                $("#subUnitId").val(res.data[0].subUnitId);
                                $("#subUnitName").val(res.data[0].subUnitName);
                                $("#subUnitRate").val(res.data[0].subUnitRate);
                                //签收数量
                                $("#signNum").val(res.data[0].signNum+""+res.data[0].mainUnitName);

                            } else {
                                layer.msg('获取入库签收产品信失败!', {icon : 2, time : 1000});
                            }
                        }, 'GET');
                    });
                    //入库仓库类型
                    admin.initDataSelect("enterprisecab/warehouse/admin/warehouseType/list", {limit: 999}, "warehouseTypeId", null, "入库仓库类型", null, null);
                    //入库仓库类型选择事件
                    form.on("select(warehouseTypeId)", function (selectData) {
                        $("#warehouseId").empty();
                        $("#warehouseAreaId").empty();
                        $("#warehouseShelfId").empty();
                        $("#warehouseShelfSpaceId").empty();
                        $("#palletBoxId").val('');
                        $("#palletBoxName").val('');
                        //入库仓库列表
                        admin.initDataSelect("enterprisecab/warehouse/admin/warehouse/list", {limit: 999, warehouseTypeId: selectData.value}, "warehouseId", null, "入库仓库", null, null);
                    });
                    //入库仓库选择事件
                    form.on("select(warehouseId)", function (selectData) {
                        $("#warehouseAreaId").empty();
                        $("#warehouseShelfId").empty();
                        $("#warehouseShelfSpaceId").empty();
                        $("#palletBoxId").val('');
                        $("#palletBoxName").val('');
                        //仓库库区列表
                        admin.initDataSelect("enterprisecab/warehouse/admin/warehouseArea/list", {limit: 999, warehouseId: selectData.value}, "warehouseAreaId", null, "仓库库区", null, null);
                    });
                    //仓库库区选择事件
                    form.on("select(warehouseAreaId)", function (selectData) {
                        $("#warehouseShelfId").empty();
                        $("#warehouseShelfSpaceId").empty();
                        $("#palletBoxId").val('');
                        $("#palletBoxName").val('');
                        //库区货架列表
                        admin.initDataSelect("enterprisecab/warehouse/admin/warehouseShelf/list", {limit: 999, queryWarehouseId: $("#warehouseId").val(),queryWarehouseAreaId: selectData.value}, "warehouseShelfId", null, "库区货架", null, null);
                    });
                    //库区货架选择事件
                    form.on("select(warehouseShelfId)", function (selectData) {
                        $("#warehouseShelfSpaceId").empty();
                        $("#palletBoxId").val('');
                        $("#palletBoxName").val('');
                        var warehouseId = $("#warehouseId").val();
                        var warehouseAreaId = $("#warehouseAreaId").val();
                        //清空库区货架信息
                        $("#warehouseShelfSpaceId").empty();
                        //货架货位列表
                        admin.initDataSelect("enterprisecab/warehouse/admin/warehouseShelfSpace/list", {limit: 999, warehouseId: warehouseId,warehouseAreaId: warehouseAreaId, shelfId: selectData.value}, "warehouseShelfSpaceId", null, "货架货位", "code", null);
                    });
                    //货架货位选择事件
                    form.on("select(warehouseShelfSpaceId)", function (selectData) {
                        //清空料箱数据
                        $("#palletBoxId").val('');
                        $("#palletBoxName").val('');
                        var e = selectData.elem;
                        var spaceCode = e[e.selectedIndex].text;
                        //货位料箱信息
                        admin.req('enterprisecab/warehouse/admin/palletBoxList/getBySpaceCode', {spaceCode: spaceCode}, function(res) {
                            if (200 == res.code) {
                                $("#palletBoxId").val(res.data.id);
                                $("#palletBoxName").val(res.data.code);
                            } else {
                                layer.msg('获取货位料箱信息失败!', {icon : 2, time : 1000});
                            }
                        }, 'GET');
                    });
                    // 监听输入框-入库数量
                    $("input[name='quantity']").on("input",function(e){
                        //入库数量
                        var quantity = e.delegateTarget.value;
                        //主计量单位换算率
                        var mainUnitRate = $("#mainUnitRate").val();
                        if(mainUnitRate == undefined || mainUnitRate == ''){
                            layer.msg("请选择签收入库产品", {icon: 2, time: 1000});
                        }
                        //辅计量单位换算率
                        var subUnitRate = $("#subUnitRate").val();
                        //辅计量单位
                        var subUnitName =  $("#subUnitName").val();
                        if(subUnitRate != '' && subUnitRate != undefined){
                            $('#subStorageWorkNum').val((quantity * mainUnitRate / subUnitRate)+""+subUnitName);
                        }
                    });
                    // 表单提交事件
                    form.on('submit(purchaseStorageWorkFormAddSubmit)', function (d) {
                        var purchaseStorageWorkProduct = {}
                        purchaseStorageWorkProduct.productDetailId = d.field.productDetailId;
                        purchaseStorageWorkProduct.warehouseInventoryTypeId = d.field.warehouseInventoryTypeId;
                        purchaseStorageWorkProduct.purchaseSignForProductId = d.field.purchaseSignForProductId;
                        purchaseStorageWorkProduct.warehouseTypeId = d.field.warehouseTypeId;
                        purchaseStorageWorkProduct.warehouseId = d.field.warehouseId;
                        purchaseStorageWorkProduct.warehouseAreaId = d.field.warehouseAreaId;
                        purchaseStorageWorkProduct.warehouseShelfId = d.field.warehouseShelfId;
                        purchaseStorageWorkProduct.warehouseShelfSpaceId = d.field.warehouseShelfSpaceId;
                        purchaseStorageWorkProduct.palletBoxId = d.field.palletBoxId;
                        purchaseStorageWorkProduct.quantity = d.field.quantity;
                        d.field.purchaseStorageWorkProduct = purchaseStorageWorkProduct;
                        console.log(d.field);
                        
                        // admin.req('enterprise/purchase/admin/purchaseStorageWork/add', JSON.stringify(d.field), function (res) {
                        //     layer.closeAll('loading');
                        //     if (res.code == 200) {
                        //         layer.msg(res.msg, {icon: 1});
                        //         table.reload('purchaseStorageWorkTable');
                        //         layer.closeAll('page');
                        //     } else {
                        //         layer.msg(res.msg, {icon: 2});
                        //     }
                        // },'POST', false, "application/json");
                        return false;
                    });
                }
            });
        }

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '80%',
                offset: '65px',
                title: data ? '修改采购入库作业' : '添加采购入库作业',
                content: $('#purchaseStorageWorkForm').html(),
                success: function () {
                    form.val('purchaseStorageWorkForm', data);

                    var codeArr = [];
                    var deliveryRecordProductList = [];

                    // 获取采购入库签收
                    admin.req('enterprise/purchase/admin/purchaseSignFor/list', {limit: 99999, filterStorageWorkComplete: 1, status: '2'}, function(res) {
                        if (200 == res.code) {
                            $("form select[name='purchaseSignForId']").append(new Option("请选择采购入库签收", ""));//往下拉菜单里添加元素
                            $.each(res.data, function(index, item) {
                                $("form select[name='purchaseSignForId']").append(new Option(item.signNo, item.id));//往下拉菜单里添加元素
                            })
                            form.render(); //菜单渲染 把内容加载进去
                            if(data && data.purchaseSignForId){
                                form.val('purchaseSignForForm', data);
                                setData(res, data.purchaseSignForId);
                            }
                            form.on("select(getPurchaseSignFor)", function (d) {
                                $("#productList").find("tbody").remove();
                                codeArr = [];
                                setData(res, d.value);
                            })
                        } else {
                            layer.msg('获取采购入库签收失败!', {icon : 2, time : 1000});
                        }
                    }, 'GET');

                    function setData(res, purchaseSignForId) {
                        var businessContact = "";
                        var departmentName = "";
                        var purchaseApplicant = "";
                        var auditorName = "";
                        var transportModeDesc = "";
                        var transportMode = "";
                        var waybillNo = "";
                        var plateNo = "";
                        var courierNo = "";
                        var phone = "";
                        var warehouseName = "";
                        if(purchaseSignForId != ""){
                            $.each(res.data, function(index, item) {
                                if(item.id == purchaseSignForId){
                                    businessContact = item.businessContact;
                                    departmentName = item.departmentName;
                                    purchaseApplicant = item.purchaseApplicant;
                                    auditorName = item.auditorName;
                                    transportMode = item.transportMode;
                                    transportModeDesc = item.transportModeDesc;
                                    waybillNo = item.waybillNo;
                                    plateNo = item.plateNo;
                                    courierNo = item.courierNo;
                                    phone = item.phone;
                                    warehouseName = item.warehouseName;
                                }
                            })
                        }else{
                            businessContact = "";
                            departmentName = "";
                            purchaseApplicant = "";
                            auditorName = "";
                            transportMode = "";
                            transportModeDesc = "";
                            waybillNo = "";
                            plateNo = "";
                            courierNo = "";
                            phone = "";
                            warehouseName = "";
                        }
                        $("#businessContact").text(businessContact);
                        $("#departmentName").text(departmentName);
                        $("#purchaseApplicant").text(purchaseApplicant);
                        $("#auditorName").text(auditorName);
                        $("#transportModeDesc").text(transportModeDesc);
                        $("#waybillNo").text(waybillNo);
                        if(transportMode == "courier"){
                            $("#variable").text("快递单号");
                            $("#plateNo").text(courierNo);
                        }else{
                            $("#variable").text("车牌号");
                            $("#plateNo").text(plateNo);
                        }
                        $("#phone").text(phone);
                        $("#warehouseName").text(warehouseName);
                    }



                    // 添加入库作业物料
                    $("#addProduct").click(function () {
                        var purchaseSignForId = $("form select[name='purchaseSignForId']").val();
                        if(purchaseSignForId){
                            var purchaseStorageWorkProductList = admin.open({
                                type: 1,
                                area: '80%',
                                offset: '65px',
                                title: '选择入库作业物料',
                                content: $('#purchaseStorageWorkProductList').html(),
                                success: function () {

                                    var codes = "";
                                    for (var i = 0; i < codeArr.length; i++) {
                                        if(i == 0){
                                            codes = '"'+codeArr[i]+'"';
                                        }else{
                                            codes += "," + '"'+codeArr[i]+'"';
                                        }
                                    }

                                    // 渲染表格
                                    var insTb = table.render({
                                        elem: '#purchaseSignForProductTable',
                                        url: config.base + 'enterprise/purchase/admin/purchaseSignForProduct/list',
                                        where: {purchaseSignForId: purchaseSignForId, filterStorageWorkComplete: 1, codes: codes},
                                        page: false,
                                        cellMinWidth: 100,
                                        cols: [[
                                            {type: 'checkbox'},
                                            {field: 'id', align: 'center', title: 'ID', hide: 'true'},
                                            {field: 'skuCode', align: 'center', title: '物料编号',width:120},
                                            {field: 'productName', align: 'center', title: '物料名称',width:120},
                                            {field: 'specifications', align: 'center', title: '规格型号',width:120},
                                            {field: 'quantity', align: 'center', title: '数量'},
                                            {field: 'unitName', align: 'center', title: '计量单位',width:100},
                                            {field: 'rate', align: 'center', title: '税率(%)'},
                                            {field: 'taxPrice', align: 'center', title: '含税单价'},
                                            {field: 'price', align: 'center', title: '单价'},
                                            {field: 'amount', align: 'center', title: '金额'},
                                            {field: 'tax', align: 'center', title: '税额'},
                                            {field: 'totalAmount', align: 'center', title: '合计金额'}
                                        ]]
                                    });

                                    // 搜索
                                    form.on('submit(deliveryRecordProductFormSubSearchLog)', function (data) {
                                        insTb.reload({where: data.field,page: {curr: 1}},'data');
                                    });

                                    // 重置搜索
                                    form.on('submit(deliveryRecordProductResets)', function (data) {
                                        $(".lay-header").find('select').val("");
                                        $(".lay-header").find('input').val("");
                                        let field = data.field;
                                        for (let key in field) {
                                            field[key] = ''
                                        }
                                        insTb.reload({where: field, page: {curr: 1}}, 'data');
                                    });

                                    // 确认选择
                                    $('#confirmChoose').click(function () {
                                        var checkStatus = table.checkStatus('purchaseSignForProductTable'); //test即为基础参数id对应的值
                                        var dataS = checkStatus.data;
                                        for (var i = 0; i < dataS.length; i++) {
                                            dataS[i].purchaseSignForProductId = dataS[i].id;
                                        }
                                        if (dataS.length == 0) {
                                            layer.msg("请选择物料", {icon: 2, time: 1000});
                                        }else{
                                            for (var i = 0; i < dataS.length; i++) {
                                                deliveryRecordProductList.push(dataS[i]);
                                                codeArr.push(dataS[i].skuCode);
                                            }
                                            layer.close(purchaseStorageWorkProductList);

                                            // 获取数据集合并传入表格中
                                            table.reload('purchaseStorageWorkProductTable', {
                                                data: deliveryRecordProductList,
                                                limit: deliveryRecordProductList.length
                                            });
                                        }
                                    });
                                }
                            });
                        }else{
                            layer.msg('请选择采购入库签收!', {icon : 2, time : 1000});
                        }
                    })

                    if(data){
                        // 获取签收物料
                        admin.req('enterprise/purchase/admin/purchaseSignForProduct/list', {limit: 99999, purchaseSignForId: data.id}, function(res) {
                            if (200 == res.code) {
                                deliveryRecordProductList = res.data;
                                for (var i = 0; i < deliveryRecordProductList.length; i++) {
                                    deliveryRecordProductList[i].purchaseSignForId = deliveryRecordProductList[i].id;
                                    codeArr.push(deliveryRecordProductList[i].skuCode);
                                }
                                table.reload('purchaseDeliveryRecordProductTable', {
                                    data: deliveryRecordProductList,
                                    limit: deliveryRecordProductList.length
                                });
                            } else {
                                layer.msg('获取签收物料失败!', {icon : 2, time : 1000});
                            }
                        }, 'GET');
                    }

                    // 渲染表格
                    var insTb = table.render({
                        elem: '#purchaseStorageWorkProductTable',
                        data: [deliveryRecordProductList],
                        page: false,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'numbers', height: 50}
                            ,{field: 'purchaseSignForProductId', title: '采购入库签收物料ID', hide: 'true'}
                            ,{field: 'productTypeId', title: '物料类型ID', hide: 'true'}
                            ,{field: 'productPic', title: '物料图片', templet: function (d) {
                                    return '<img src="' + d.productPic + '" style="height: 40px;" id="platformPic"/>'
                                }}
                            ,{field: 'skuCode', title: '物料编号', width: 120}
                            ,{field: 'specifications', title: '规格号'}
                            ,{field: 'productTypeName', title: '物料类型'}
                            ,{field: 'unitName', title: '计价单位'}
                            // ,{field: 'purchaseQuantity', title: '采购数量'}
                            // ,{field: 'quantity', title: '发货数量'}
                            // ,{field: 'hasSignQuantity', title: '已签收数'}
                            // ,{field: 'surplusSignQuantity', title: '剩余签收数', templet: function (d) {
                            //         return d.quantity - d.hasSignQuantity;
                            //     }}
                            // ,{field: '', title: '是否包装', width: 120, templet: '#hasPack'}
                            ,{field: 'productPackName', align:'center', title: '包装方式', width: 120,
                                templet: '<div><input type="hidden" name="productPackId" lay-verify="productPack" value="{{d.productPackId != null ? d.productPackId : \'\'}}" /><span class="productPack" style="display: block;cursor: pointer;" data-add="{{d.productPackName != null ? false : true}}">{{d.productPackName != null ? d.productPackName : "请选择"}}</span></div>'}
                            ,{field: 'packUnit', title: '包装单位', width: 120}
                            ,{field: 'conversionRate', title: '换算率', width: 120}
                            ,{field: 'signForPackNum', title: '签收数量(按包装)', width: 140}
                            ,{field: 'signForBaseNum', title: '签收数量(按基础单位)', width: 170}
                            ,{align: 'center', toolbar: '#purchaseDeliveryRecordProductTableBar', title: '操作', width: 100, fixed: 'right'}
                        ]]
                    });

                    // 工具条点击事件
                    table.on('tool(purchaseStorageWorkProductTable)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'del') { // 删除
                            doDelete(obj);
                        }
                    });

                    // 删除签收物料
                    function doDelete(obj) {
                        var index = $(obj.tr).data("index");
                        layer.confirm('确定要删除吗？', {
                            offset: '65px',
                            skin: 'layui-layer-admin'
                        }, function (i) {
                            layer.close(i);
                            var skuCode = obj.data.skuCode;
                            if(codeArr.indexOf(skuCode) != -1){
                                deliveryRecordProductList.splice(index,1);
                                codeArr.splice(codeArr.indexOf(skuCode), 1);
                            }
                            table.reload('purchaseStorageWorkProductTable', {
                                data: deliveryRecordProductList,
                                limit: deliveryRecordProductList.length
                            });
                        });
                    }
                }
            });
        }

        // 显示详情弹窗
        function showViewModel(data) {
            admin.open({
                type: 1,
                area: '60%',
                title: '采购入库作业详情',
                content: $('#purchaseStorageWorkView').html(),
                success: function () {
                    //数据回显
                    if(data.subUnitRate != '' && data.subUnitRate != undefined){
                        data.subUnitNum = (data.quantity * data.mainUnitRate / data.subUnitRate)+""+data.subUnitName
                    }
                    form.val('purchaseStorageWorkView', data);
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprise/purchase/admin/purchaseStorageWork/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field,page: {curr: 1}},'data');
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            let field = data.field;
            for (let key in field) {
                field[key] = ''
            }
            insTb.reload({where: field, page: {curr: 1}}, 'data');
        });

        // 导出excel
        $('#purchaseStorageWorkBtnExport').click(function () {
            var checkRows = table.checkStatus('purchaseStorageWorkTable');
            if (checkRows.data.length == 0) {
                layer.msg('请选择要导出的数据', {icon: 2});
            } else {
                table.exportFile(insTb.config.id, checkRows.data, 'xls');
            }
        });

        /*渲染下拉框*/
        function loadSelectHtml(data, tips, htmltarget, type, showValue) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                if (type === 1) {
                    html += `<option value='${data[i].id}'>${data[i].skuCode}</option>`;
                } else if(type === 2) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                }else if(type == 6){
                    html += `<option value='${data[i].code}'>${data[i].name}</option>`;

                }
            }

            $("form select[name='" + htmltarget + "']").html(html);

            if(showValue != '') {
                $('#'+ htmltarget +' option[value=' + showValue + ']').attr('selected', true)
            }

            form.render('select');
        }


        //  导出
        $('#workStorageBtnExport').click(function () {
            let skuCode = $('#skuCode').val();
            let skuName = $('#skuName').val();
            let workNo = $('#workNo').val();
            let warehouseShelfSpaceCode = $('#warehouseShelfSpaceCode').val();
            // 创建一个对象来保存所有可能的查询参数
            let queryParams = {
                skuCode: skuCode,
                skuName: skuName,
                workNo: workNo,
                warehouseShelfSpaceCode: warehouseShelfSpaceCode
            };

            // 过滤掉值为 undefined 的属性
            queryParams = Object.keys(queryParams)
                .filter(key => queryParams[key] !== undefined && queryParams[key] !== '')
                .reduce((obj, key) => {
                    obj[key] = queryParams[key];
                    return obj;
                }, {});

            // 将过滤后的参数对象转换为查询字符串
            let queryString = new URLSearchParams(queryParams).toString();

            // 获取当前日期和时间
            let now = new Date();
            let year = now.getFullYear();
            let month = String(now.getMonth() + 1).padStart(2, '0'); // 注意：getMonth() 返回值是 0-11
            let day = String(now.getDate()).padStart(2, '0');
            let hour = String(now.getHours()).padStart(2, '0');
            let minute = String(now.getMinutes()).padStart(2, '0');
            let second = String(now.getSeconds()).padStart(2, '0');

            // 格式化日期和时间为 YYYYMMDD_HHMMSS 形式
            let formattedDateTime = `${year}${month}${day}_${hour}${minute}${second}`;

            // 设置下载文件名为 "产品数据_YYYYMMDD_HHMMSS.xls"
            let fileName = `入库作业数据表_${formattedDateTime}.xls`;

            // 创建完整的URL，包括查询参数和文件名作为额外参数（如果后端支持的话）
            let fullUrl = config.base + 'enterprise/purchase/admin/purchaseStorageWork/export?' + queryString + '&fileName=' + encodeURIComponent(fileName);

            // 使用 window.open 打开新页面进行下载
            window.open(fullUrl + '&Authorization=Bearer ' + encodeURIComponent(config.getToken()), '_blank');
            // 注意：这里假设后端能够处理 fileName 参数，并根据它设置响应头中的 Content-Disposition 来指定下载文件名。
            // 如果后端不支持通过 URL 参数指定文件名，你可能需要调整后端代码来接受这种请求方式。
        });

    });
</script>